package com.zkr.thresho.mapper;

import com.zkr.thresho.model.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by lenovo on 2020/12/16.
 */
@Mapper
public interface ThreshoMapper {

    int queryCount(ThreshoSelectVo threshoSelectVo);

    List<ThreshoSelectVo> query(ThreshoSelectVo threshoSelectVo);

    @Select(" select *,legalPersonId id from legalperson  where userId =#{userId}")
    List<LegalPersonVo> queryLegalPersonById(Integer userid);

    @Select("select code,name from subclass")
    List<SubClassVo> querySubClass();



    @Insert("insert into thresho(legalPersonCode,materialCode,threshonum,remark,updateName,updateTime)"+
    "values(#{legalPersonCode},#{materialCode},#{threshonum},#{remark},#{updateName},#{updateTime})")
    void insertPlantClass(@Valid List<ThreshoAddVo> threshoAddVoList);

    List<LagalSpareVo> queryLagalSaper(LagalSpareVo lagalSpareVo);

    List<SpareSelectVo> querySpare(SpareSelectVo spareSelectVo);

    void update(SpareSelectVo spareSelectVo);

    //@Select("select materialCode from thresho where materialCode = #{materialCode}")
    //SpareSelectVo queryByCode(@NotBlank(message = "备件编码不能为空") String materialCode);

    @Select("select threshonum from thresho where threshonum=#{threshonum}")
    SpareSelectVo queryByThreshonum(@NotNull(message = "数量阀值不能为空") @Max(message = "数量阀值不能超过9999", value = 9999) Integer threshonum);

    @Select("select * from thresho where threshoId=#{threshoId}")
    SpareSelectVo queryThreshoId(Integer threshoId);


    List<String> queryByCodes(List<String> codeList);

    @Select("select materialCode from thresho where materialCode = #{materialCode}")
    List<ThreshoAddVo> queryByCode(List<ThreshoAddVo> threshoAddVoList);

    @Select("select * from thresho where threshoId=#{threshoId}")
    List<ThreshoAddVo> queryThresho(List<ThreshoAddVo> threshoAddVoList);

    @Select("select legalPersonCode,legalPersonName from legalperson where legalPersonCode=#{legalPersonCode}")
    List<String> queryLegalPersonCode(List<String> person);

    List<ThreshoSelectVo> queryExportData(ThreshoSelectVo threshoSelectVo);


/*
    @Select("select * from spare where materialCode=#{materialCode} ")
    ThreshoSelectVo queryByCode(@NotBlank(message = "备件编码不能为空") String materialCode);*/











    /*List<LegalPlantClassVo> query(LegalPersonSelectVo legalPersonSelectVo);

    int queryCount(LegalPersonSelectVo planClassSelectVo);

    void updateStatus(LegalPlantClassVo legalPlantClassVo);

    @Select("select * from legalplant where legalPlantCode=#{legalPlantCode}")
    LegalPlantClassVo queryByCode(String legalPersonCode);


    @Insert("insert into legalplant(legalPlantCode,legalPlantDec,legalPersonCode,enabled,createTime,createName,updateTime,updateName) "+
            "values (#{legalPlantCode},#{legalPlantDec},#{legalPersonCode},#{enabled},#{createTime},#{createName},#{updateTime},#{updateName}) ")
    void insertPlantClass(LegalPlantClassVo legalPlantClassVo);

    @Select("select *,legalPersonId id from legalperson  where userId = #{userid} ")
    List<LegalPersonVo> queryLegalPersonById(Integer userid);

    void update(LegalPlantClassVo legalPlantClassVo1);

    @Select("select * from legalplant where legalPlantCode=#{legalPlantCode}")
    LegalPlantClassVo queryById(@NotBlank(message = "工厂编码不能为空!") String legalPlantCode);*/

}
